package com.kehutong.common.worker;

import java.time.LocalDateTime;

import org.coraframework.util.Objects;

/**
 * @author liuzhen (liuxing521a@163.com)
 * @createTime 2020年6月5日下午7:11:14
 */
public interface Worker<E extends Worker<E>> extends Runnable, Comparable<E> {

	String getId();
	
	boolean sendAble();
	
	boolean isEffect();
	
	LocalDateTime getHandTime();

	default void setEffect(boolean effect) {
		
	}
	
	
	@Override
	default int compareTo(E o) {
		if (Objects.isNull(o.getHandTime()) || Objects.isNull(getHandTime())) {
			return 0;
		}
		
		if (o.getHandTime().isAfter(getHandTime())) {
				return -1;
		}
		
		if (o.getHandTime().isBefore(getHandTime())) {
			return 1;
		}
		
		return 0;
	}
}
